<!DOCTYPE HTML>
<html>

<head>
    <meta charset="UTF-8" />
    <meta name="description"
        content="360天气，为您提供最精准的天气信息。您更可以通过下载360天气手机客户端，随时随地关注天气情况。更能体验空气质量信息、生活指数信息、亲情天气功能、网友报天气功能、天气吐槽功能。" />
    <title>360天气</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    <link rel="shortcut icon" href="http://p8.qhimg.com/t0158c24c5ddb3a6745.png" type="image/x-icon" />
    <link rel="stylesheet" href="http://s9.qhres.com/static/dde91e3f96d3f331.css" />
    <script name="jquery" src="http://s0.qhimg.com/lib/jquery/183.js"></script>
    <style type="text/css">
        #weathertype {
            font-size: 28px;
            padding-left: 20px
        }

        #copyright {
            padding: 40px 0;
            text-align: center;
            line-height: 2;
            color: #999
        }

        .btn-app {
            background: url(http://p6.qhimg.com/t01c34fd5acfdd9ce43.png) no-repeat 0 0
        }

        .skinmore,
        .skinmore2 {
            z-index: -1
        }

        .skin2 .skinmore2 {
            background: url(http://p4.qhimg.com/t0191e46e3e10bc96e3.png) repeat center 0;
            height: 100%;
            left: 0;
            position: absolute;
            top: 0;
            width: 100%
        }

        .qrcodes img {
            margin-top: 40px
        }

        .qrcodes {
            position: absolute;
            top: 150px;
            width: 200px;
            right: 2%
        }

        .header {
            height: 110px
        }

        .logo {
            background: url(http://p4.qhmsg.com/t0127467a51cdc489fc.png) no-repeat;
            background-image: -webkit-image-set(url(http://p4.qhmsg.com/t0127467a51cdc489fc.png) 1x, url(http://p0.qhimg.com/t01ea0b4aedd360d174.png) 2x);
            float: left;
            height: 65px;
            margin-top: 35px;
            width: 183px
        }

        .search {
            margin-top: 20px
        }
    </style>
</head>

<body class="skin1">
    <!--　skin1晴天　skin2雷电　skin3沙尘　skin4雾　skin5雪 skin6雨 -->
    <div class="skinmore"></div>
    <div class="skinmore2"></div>
    <div class="tab">
        <ul>
            <li class="current"><a href="">查看天气</a></li>
            <li><a href="introduce.html">360天气介绍</a></li>
            <li><a href="wlicense.html">许可协议</a></li>
        </ul>
    </div>
    <div class="content">
        <div class="city">
            <select id="province">

            </select>
            <select id="city">

            </select>
            <select id="town">

            </select>
            <input type="button" value="更换" class="citybtn">
        </div>
        <!-- S 具体城市天气及右侧ＡＰＰ下载　-->
        <div class="wether">
            <div class="wetherintro">
                <div id="cityinfo">
                    <h4 class="wethercity"></h4>
                    <p class="wethertime"></p>
                    <!--　各状态为yanzhong zhongdu zhong qing liang youxiu -->
                    <span class="wethericon" id="aqi"></span>
                </div>
                <div class="wetherdetail">
                    <strong id="temperature"> </strong><span id="weathertype"></span>
                    <ul>
                        <li><i class="icon-shi"></i>湿度 <span id="humidity"></span>%</li>
                        <li class="txt-r"><i class="icon-feng"></i><span id="winddir"></span> <span
                                id="windpower"></span></li>
                    </ul>
                </div>
            </div>
            <div class="wetherapp">
                <img src="http://p1.qhimg.com/t012106e01f86dfafca.png" />
                <p class="wetherapptxt">360天气，知冷暖，更懂你</p>
            </div>
        </div>
        <!-- E 具体城市天气及右侧ＡＰＰ下载　-->
        <!-- S 更多日期天气　-->
        <div class="morewether">
            <!--　各天气对应中文拼音　如icon-yewanqing对应“夜晚晴“ -->
            <ul id="foreast">

            </ul>
        </div>

    </div>

    <script>
        function addFavorite() {
            var e = window.location.href,
                t = "360天气",
                n = navigator.userAgent.toLowerCase().indexOf("mac") != -1 ? "Command/Cmd" : "CTRL";
            try {
                window.external.addFavorite(e, t)
            } catch (r) {
                try {
                    window.sidebar.addPanel(t, e, "")
                } catch (r) {
                    alert("您可以尝试通过快捷键" + n + " + D 加入到收藏夹~")
                }
            }
            return !1
        }
        function appendOption(e, t) {
            e.children().remove();
            var n = new Array;
            for (var r = 0; r < t.length; r++) {
                var i = t[r][0],
                    s = t[r][1],
                    o = optionTemp.replace(/\$\(code\)/g, s).replace(/\$\(name\)/g, i);
                n.push(o)
            }
            e.append(n.join(""))
        }
        function selectOption(e, t) {
            e.children("option").each(function () {
                var e = $(this);
                e.val() == t && e.attr("selected", "selected")
            })
        }
        function loadProvince(e) {
            appendOption(p, e),
                selectOption(p, pCode)
        }
        function loadCity(e) {
            appendOption(c, e),
                selectOption(c, cCode)
        }
        function loadTown(e) {
            appendOption(t, e),
                selectOption(t, tCode)
        }
        function loadCity2(e) {
            loadCity(e),
                c.trigger("change")
        }
        function dataFill(e, t) {
            t.html(e)
        }
        function fillRealtime(e) {
            var t = e.time,
                n = t.split(":")[0],
                r = t.split(":")[1];
            dataFill(n + " : " + r + " 发布", $(".wethertime"));
            var i = e.weather.temperature;
            dataFill(i + "°", $("#temperature"));
            var s = e.weather,
                o = s.info;
            dataFill(o, $("#weathertype"));
            var u = s.humidity;
            dataFill(u, $("#humidity"));
            var a = e.wind,
                f = a.direct;
            dataFill(f, $("#winddir"));
            var l = a.power;
            dataFill(l, $("#windpower")),
                $(".wetherdetail").children("ul").show(),
                $("#cityinfo").show()
        }
        function fillForeast(e) {
            var t = $("#foreast");
            t.children().remove();
            for (var n = 1; n < 6; n++) {
                var r = e[n],
                    i = r.date.split("-"),
                    s = i[0],
                    o = i[1].indexOf("0") == 0 ? i[1].substr(1) : i[1],
                    u = i[2].indexOf("0") == 0 ? i[2].substr(1) : i[2],
                    a = "",
                    f = $(this);
                if (n == 0) a = "今天";
                else {
                    var l = new Date(parseInt(s), parseInt(o) - 1, parseInt(u));
                    a = "周" + weekChina[l.getDay()]
                }
                var c = f.children(),
                    h = r.info.day,
                    p = r.info.night,
                    d = h[1],
                    v = h[1],
                    m = d == v ? d : d + "转" + v,
                    g = weatherClass[d] ? weatherClass[d] : "icon-wuxinxi",
                    y = h[2],
                    b = p[2],
                    w = h[4],
                    E = foreastTemp.replace(/\$\(week\)/g, a).replace(/\$\(month\)/g, o).replace(/\$\(day\)/g, u).replace(/\$\(icon\)/g, g).replace(/\$\(weatherType\)/g, m).replace(/\$\(lowT\)/g, b).replace(/\$\(highT\)/g, y).replace(/\$\(windpower\)/g, w);
                t.append($(E))
            }
        }
        function fillAQI(e) {
            var t = ["zhongdu", "重度污染"];
            for (var n = 0; n < aqiLevel.length; n++) if (e >= aqiLevel[n][0] && e < aqiLevel[n][1]) {
                t = alertMap[n];
                break
            }
            $("#aqi").attr("class", "wethericon"),
                $("#aqi").addClass(t[0]),
                $("#aqi").html(t[1] + " " + e),
                $("#aqi").show()
        }
        function renderData(e) {
            $("body").hide();
            var t = e.area[2][0],
                n = e.area[2][1];
            dataFill(t, $(".wethercity"));
            var r = e.realtime;
            fillRealtime(r);
            var i = r.weather.info;
            i == "阴" ? $(".skinmore").hide() : $(".skinmore").show();
            var s = skins[i] ? skins[i] : "skin1";
            $("body").attr("class", s);
            var o = e.weather;
            fillForeast(o),
                e.pm25 && e.pm25.aqi ? fillAQI(e.pm25.aqi) : $("#aqi").hide(),
                $("body").show(),
                document.cookie = "citycode=" + n + "; "
        }
        function getCityCode(e) {
            var t = e.area;
            pCode = t[0][1],
                cCode = t[1][1],
                tCode = t[2][1],
                setSelector(),
                loadWeather(tCode)
        }
        function setSelector() {
            $.getScript("http://cdn.weather.hao.360.cn/sed_api_area_query.php?grade=province&_jsonp=loadProvince"),
                $.getScript("http://cdn.weather.hao.360.cn/sed_api_area_query.php?grade=city&_jsonp=loadCity&code=" + pCode),
                $.getScript("http://cdn.weather.hao.360.cn/sed_api_area_query.php?grade=town&_jsonp=loadTown&code=" + cCode)
        }
        function noinfo() {
            $("#weathertype").html("暂无数据"),
                $("#temperature").html(""),
                $("#foreast").children().remove(),
                $(".wetherdetail").children("ul").hide(),
                $("#cityinfo").hide()
        }
        function codeselect(e) {
            var t = (new Date).getTime(),
                n = parseInt(e) + (new Date).getTime(),
                r = [t, n];
            return r
        }
        function loadWeather(e) {
            var t = codeselect(e);
            $.ajax("http://tq.360.cn/api/weatherquery/querys?app=tq360&code=" + e + "&t=" + t[0] + "&c=" + t[1], {
                dataType: "jsonp",
                jsonp: "_jsonp",
                jsonpCallback: "renderData",
                error: noinfo
            })
        }
        function setArea() {
            var e = document.cookie,
                t = "";
            if (e) {
                var n = e.split("; ");
                for (var r = 0; r < n.length; r++) {
                    var i = n[r].split("="),
                        s = i[0];
                    if (s != "citycode") continue;
                    t = i[1];
                    break
                }
            }
            t ? (pCode = t.substr(3, 2), pCode == "01" || pCode == "02" || pCode == "03" || pCode == "04" ? cCode = pCode + "01" : cCode = t.substr(3, 4), tCode = t, setSelector(), loadWeather(tCode)) : $.getScript("http://weather.hao.360.cn/sed_api_weather_info.php?app=clockWeather&_jsonp=getCityCode")
        }
        function changeCity() {
            loadWeather(t.val())
        }
        var weekChina = ["日", "一", "二", "三", "四", "五", "六"],
            weatherClass = {
                "晴": "icon-qing",
                "多云": "icon-duoyun",
                "阴": "icon-yintian",
                "雾": "icon-wu",
                "冰雹": "icon-bingbao",
                "扬沙": "icon-shachen",
                "沙尘": "icon-shachen",
                "浮尘": "icon-shachen",
                "霾": "icon-shachen",
                "大雨-暴雨": "icon-dayu",
                "雷阵雨": "icon-leizhenyu",
                "阵雨": "icon-zhenyu",
                "雨": "icon-xiaoyu",
                "小雨": "icon-xiaoyu",
                "中雨": "icon-zhongyu",
                "大雨": "icon-dayu",
                "暴雨": "icon-baoyu",
                "雨夹雪": "icon-yujiaxue",
                "阵雪": "icon-chenxue",
                "小雪": "icon-xiaoxue",
                "雪": "icon-xiaoxue",
                "中雪": "icon-zhongxue",
                "大雪": "icon-daxue",
                "暴雪": "icon-baoxue",
                "阵雪": "icon-baoyu"
            },
            foreastTemp = '<li><p class="colora">$(week) $(month)月$(day)日</p><p class="icon-tu"><i class="$(icon)"></i><br>$(weatherType)</p><p class="otherinfo"><span>$(lowT)~$(highT)°</span>$(windpower)</p></li>',
            aqiLevel = [[0, 50], [50, 100], [100, 150], [150, 200], [200, 300], [300, Number.MAX_VALUE]],
            alertMap = [["youxiu", "空气优"], ["liang", "空气良"], ["qing", "轻度污染"], ["zhong", "中度污染"], ["zhongdu", "重度污染"], ["yanzhong", "严重污染"]],
            skins = {
                "晴": "skin1",
                "多云": "skin1",
                "阴": "skin6",
                "雾": "skin4",
                "冰雹": "skin5",
                "扬沙": "skin3",
                "沙尘": "skin3",
                "浮尘": "skin3",
                "霾": "skin3",
                "烟霾": "skin3",
                "雷阵雨": "skin2",
                "雷雨": "skin2",
                "阵雨": "skin6",
                "雨": "skin6",
                "小雨": "skin6",
                "中雨": "skin6",
                "大雨": "skin6",
                "暴雨": "skin6",
                "雨夹雪": "skin5",
                "阵雪": "skin5",
                "小雪": "skin5",
                "雪": "skin5",
                "中雪": "skin5",
                "大雪": "skin5",
                "暴雪": "skin5",
                "阵雪": "skin5"
            }
    </script>

    <script type="text/javascript">
        optionTemp = '<option value="$(code)">$(name)</option>',
            p = $("#province"),
            c = $("#city"),
            t = $("#town")
    </script>

    <script type="text/javascript">
        $(function () {
            setArea(),
                p.change(function () {
                    $.getScript("http://cdn.weather.hao.360.cn/sed_api_area_query.php?grade=city&_jsonp=loadCity2&code=" + p.val())
                }),
                c.change(function () {
                    $.getScript("http://cdn.weather.hao.360.cn/sed_api_area_query.php?grade=town&_jsonp=loadTown&code=" + c.val())
                }),
                $(".citybtn").click(changeCity)
        })
    </script>
</body>

</html>